package queped;

import modeller.databasedesignmodel.DatabaseDesign;
import modeller.databasedesignmodel.servicedemand.IServiceDemand;
import modeller.databasedesignmodel.transaction.Transaction;
import modeller.queueingnetworksmodel.probabilities.TransactionRoutingMatrix;
import modeller.queueingnetworksmodel.visits.VisitMatrix;

import java.util.*;

/**
 * Created by IntelliJ IDEA.
 * User: Jason
 * Date: 19/11/2011
 * Time: 15:02
 */
public class Main {

    /**
     * Main entry point for QuePED++
     * Takes in a specified input file (-i), otherwise specified manually
     * Can solve directly by JMT if required (-J)
     * Can specify scaling factor to vary table sizes (-s), default = 1
     * @param args
     */
    public static void main(String[] args) {

        QuePEDExecution thisExecution = new QuePEDExecution(args);

        // generate Database Design
        DatabaseDesign specDesign = thisExecution.generateDatabaseDesign();

        // calculate service demands for this design
        HashMap<Transaction, IServiceDemand> serviceDemands
                = thisExecution.generateServiceDemands(specDesign);

        // generate transaction routing matrix
        TransactionRoutingMatrix qMatrix
                = thisExecution.generateTransactionRoutingMatrix(specDesign);

        // generate visit matrix
        VisitMatrix visitMatrix = new VisitMatrix();
        // generate and save QN
        String outputJSIMGFileName
                = thisExecution.generateAndSaveQN(specDesign, qMatrix, serviceDemands);

        // solve via JMT if the option is set ...
        thisExecution.solveIfRequired(outputJSIMGFileName);

        System.out.println("Finished.");

    }
}
